<template>
  <div class="child">
    子组件2（弟弟）

    <p>哥哥给的玩具:{{ toy }}</p>
  </div>
</template>

<script setup lang="ts" name="Childs2">
import emitter from "../../../../utils/emitter";
import { ref, onUnmounted } from "vue";
const toy = ref("");

// 绑定事件
emitter.on("send-toy", (value: any) => {
  toy.value = value;
});

onUnmounted(() => {
  emitter.off("send-toy");
});
</script>

<style scoped lang="scss">
.child {
  background-color: pink;
  padding: 10px;
}
</style>
